#include<bits/stdc++.h>
#define M 100010
#define inf 1000010
#define rep(x,y,z) for (int x=y;x<=z;x++)
using namespace std;
typedef double db;
int T,n,m,L,V,v1,d1,a1,p[M],a[M],s[M],ans1,ans2;
db d2,c[M];
bool f1,f2,f3;
vector <int> car;
inline void work1(int id){
    d2=c[id];
    if (d2>=1.0*p[m]) return;
    ans1++;

    f2=false;
    f3=false;


}
inline void work2(int id){
    d2=c[id];
    if (d2>p[m]*1.0) return ;
    ans1++;
    f1=false;
    f3=false;



}
inline void work3(int id){
    d2=c[id];
    if (d2<=0)  return ;
    bool flag=true;
    for (int i=1;i<=m;i++){
        if (s[id]<=p[i] && p[i]<=d2) {
            flag=false;
            break;
        }

    }
    if (flag) return ;
    ans1++;
    f2=false;
    f1=false;



}

int main(){

    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>T;
    while(T--){

        cin>>n>>m>>L>>V;
        ans1=0,ans2=0;
        f1=true,f2=true,f3=true;
        rep(i,1,n){
            cin>>d1>>v1>>a1;
            if (a1==0) {

                if (v1>V) d2=d1;
                else d2=inf;
            }
            else{

                d2=(V*V-v1*v1)*1.0/(2*a1)+d1;


            }


        }
        rep(i,1,m) cin>>p[i];
        rep(i,1,n){// ans1;

            if (a[i]>0){
                work1(i);

            }
            else if (a[i]==0){

                work2(i);
            }
            else{
                work3(i);
            }



        }
        if (ans1==0) ans2=m;
        else if (f1 || f2) ans2=m-1;
        else ans2=0;

        cout<<ans1<<' '<<ans2<<'\n';

    }

}
